package tcu.ead2021.entity;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
public class R<T> {

    private Integer code;
    private String msg;
    private T data;

    public static <T> R<T> ok(T data){
        R r = new R();
        r.setCode(200);
        r.setMsg("OK");
        r.setData(data);
        return r;
    }

    public static <T> R<T> failed(String msg){
        R r = new R();
        r.setCode(400);
        r.setMsg(msg);
        return r;
    }
}
